//
//  HAUserViewController.m
//  HorsemanApp
//
//  Created by qyc on 2019/7/26.
//  Copyright © 2019 q. All rights reserved.
//

#import "HAUserViewController.h"
#import "UserLoginViewController.h"

@interface HAUserViewController ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *verLabel;

@end

@implementation HAUserViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self configNavigationTitle:@"我的"];
    
    self.view.backgroundColor = UIColorFromRGB(0xf5f5f5);
    
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    //当前的版本
    self.verLabel.text = [NSString stringWithFormat:@"V%@",[infoDict objectForKey:@"CFBundleShortVersionString"]];
    // info
    self.nameLabel.text = [NSString stringWithFormat:@"您好,%@",[[ReadWriteUserInfoTool sharedUserInfo] getUserMobile]];
    // Do any additional setup after loading the view from its nib.
}

- (IBAction)contactSender:(id)sender {
    NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"telprompt://%@",[[ReadWriteUserInfoTool sharedUserInfo] getCustomer_tel]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil];
}

- (IBAction)outLoginSender:(id)sender {
    UIAlertController *exitController = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否退出当前账号" preferredStyle:UIAlertControllerStyleAlert];
    [exitController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [CustomProgressHUD showMessage:@"退出登录成功" time:0];
        // 清除id
        NSDictionary *info = [[NSDictionary alloc] init];
        [UserDefaultHelper setDict:info forKey:UserInfoKey];
        
        UserLoginViewController *vc = [[UserLoginViewController alloc] init];
        [UIApplication sharedApplication].keyWindow.rootViewController = vc;
    }]];
    [exitController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
    [self presentViewController:exitController animated:YES completion:nil];
    
   
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
